package com.ikingtech.platform.service.system.organization.service;

import com.ikingtech.framework.sdk.department.api.DeptOrgApi;
import com.ikingtech.framework.sdk.department.model.DeptOrgDTO;
import com.ikingtech.framework.sdk.utils.Tools;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author tie yan
 */
@Service
@RequiredArgsConstructor
public class DeptOrgService implements DeptOrgApi {

    private final OrganizationService orgService;

    @Override
    public List<DeptOrgDTO> loadByIds(List<String> orgIds) {
        if(Tools.Coll.isBlank(orgIds)){
            return new ArrayList<>();
        }
        return Tools.Coll.convertList(this.orgService.listByIds(orgIds), entity -> Tools.Bean.copy(entity, DeptOrgDTO.class));
    }

    @Override
    public DeptOrgDTO loadById(String orgId) {
        return Tools.Bean.copy(this.orgService.getById(orgId), DeptOrgDTO.class);
    }
}
